package com.oo.parkinglot;
//封装
//可读性
//对象比较

import java.util.List;
import java.util.stream.Collectors;

public class ParkingBoy extends AbstractParkingRule {

    public ParkingBoy(List<ParkingLot> parkingLots) {
        this.parkingLots = parkingLots;
    }

    @Override
    protected ParkingLot whichParkingLot2Park() {
        List<ParkingLot> availParks = parkingLots
                .stream()
                .filter(park -> park.getAvailable() > 0)
                .collect(Collectors.toList());

        return availParks.isEmpty() ? null : availParks.get(0);
    }


}
